package com.qf.service.impl;

import com.qf.dao.ComplaintsFormDao;
import com.qf.pojo.ComplaintsForm;
import com.qf.pojo.resp.BaseResult;
import com.qf.service.ComplaintsFormService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ComplaintsFormServiceImpl implements ComplaintsFormService {

    BaseResult baseResult = new BaseResult();
    @Resource
    ComplaintsFormDao complaintsFormDao;

    @Override
    public BaseResult findAllComplaints() {
        List<ComplaintsForm> allComplaints = complaintsFormDao.findAllComplaints();
        baseResult.setCode(1);
        baseResult.setData(allComplaints);
        return baseResult;
    }

    @Override
    public BaseResult addOne(ComplaintsForm complaintsForm) {
        Integer one = complaintsFormDao.addOne(complaintsForm);
        if(one>0){
            baseResult.setCode(1);
            baseResult.setInfo("提交成功");
            baseResult.setData(one);
            return baseResult;
        }
        baseResult.setCode(0);
        baseResult.setInfo("提交失败");
        return baseResult;
    }
}
